package com.czk.netty.nio.basic;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

/**
 * 通道实现文件拷贝
 *
 * @Author:ChenZhangKun
 * @Date: 2021/1/11 20:51
 */
public class TransferChannel {
    public static void main(String[] args) throws IOException {
        FileInputStream fileInputStream = new FileInputStream("D:\\简历\\x.txt");
        // 拿到通道
        FileChannel channel1 = fileInputStream.getChannel();
        // 拿到输出流
        FileOutputStream fileOutputStream = new FileOutputStream("D:\\简历\\5.txt");
        // 拿到通道
        FileChannel channel = fileOutputStream.getChannel();
        // 拷贝
        channel.transferFrom(channel1, 0, channel1.size());
    }
}
